<?php
class NewDir extends Action {
	/* (non-PHPdoc)
	 * @see Action::execute()
	 */
	public function execute($params) {
		PluginManager::enabled ( 'cn.usephp.filemgr');
		$me = check_login ( ADMIN_LOGIN_PAGE );
		$data = array ('success' => false );
		$pwd = rqst ( 'pwd', '' );
		$dname = rqst ( 'dname' );
		if (! empty ( $pwd )) {
			$pwd = "/{$pwd}";
		}
		if (empty ( $dname )) {
			$data ['msg'] = '目录名不能为空.';
		} else {
			$file = getFileSystem ();
			if ($file) {
				if ($file->mkdir ( "{$pwd}/{$dname}", 0755 )) {
					$data ['success'] = true;
				} else {
					$data ['msg'] = "创建目录失败：\n" . $file->get_errors ();
				}
			} else {
				need_transit ( 'filesmgr', $this->url );
			}
		}
		return new JsonView ( $data );
	}
}